package com.ada;

import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiGettokenRequest;
import com.dingtalk.api.request.OapiUserGetRequest;
import com.dingtalk.api.response.OapiGettokenResponse;
import com.dingtalk.api.response.OapiUserGetResponse;
import com.taobao.api.ApiException;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args ) throws ApiException {
        DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
        OapiGettokenRequest request = new OapiGettokenRequest();
        request.setAppkey("dinghgipkq3i1vhmjtdo");
        request.setAppsecret("Gnd8W29vWLFDPFC16ClIn5HBbN2Mt3MzGpIicIkKk1tLaZfF5UAX8K7lzFr8RSEI");
        request.setHttpMethod("GET");
        OapiGettokenResponse response = client.execute(request);
        System.out.println(response.getBody());
        System.out.println(response.getAccessToken());
    }
    public static String getAccessToken() throws ApiException {
        String accton;
        DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
        OapiGettokenRequest request = new OapiGettokenRequest();
        request.setAppkey("dinghgipkq3i1vhmjtdo");
        request.setAppsecret("Gnd8W29vWLFDPFC16ClIn5HBbN2Mt3MzGpIicIkKk1tLaZfF5UAX8K7lzFr8RSEI");
        request.setHttpMethod("GET");
        OapiGettokenResponse response = client.execute(request);
        System.out.println(response.getBody());
        accton=response.getAccessToken();
        return accton;
    }
}
